package org.keyory.map_editor.model;

import java.awt.image.BufferedImage;
import java.io.File;
import java.util.ArrayList;
import java.util.List;

import javax.swing.JDialog;
import javax.swing.JFrame;

public abstract class EditableMap implements Drawable {
	protected String name;
	protected int x, y, width, height;
	protected int gridWidth, gridHeight;

	protected List<File> floorSource = new ArrayList<File>();
	protected List<File> itemSource = new ArrayList<File>();

	protected BufferedImage[] floorImage = new BufferedImage[256];
	protected BufferedImage[] itemImage = new BufferedImage[256];

	protected List<Item> items = new ArrayList<Item>();

	protected int[][] floor;
	protected byte[][] blocks;

	public String getName() {
		return name;
	}

	public int getX() {
		return x;
	}

	public int getY() {
		return y;
	}

	public int getWidth() {
		return width;
	}

	public int getHeight() {
		return height;
	}

	public int getGridWidth() {
		return gridWidth;
	}

	public int getGridHeight() {
		return gridHeight;
	}

	public List<File> getFloorSource() {
		return floorSource;
	}

	public List<File> getItemSource() {
		return itemSource;
	}

	public BufferedImage[] getFloorImage() {
		return floorImage;
	}

	public BufferedImage[] getItemImage() {
		return itemImage;
	}

	public List<Item> getItems() {
		return items;
	}

	public int[][] getFloor() {
		return floor;
	}

	public byte[][] getBlocks() {
		return blocks;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setX(int x) {
		this.x = x;
	}

	public void setY(int y) {
		this.y = y;
	}

	public void setWidth(int width) {
		this.width = width;
	}

	public void setHeight(int height) {
		this.height = height;
	}

	public void setGridWidth(int gridWidth) {
		this.gridWidth = gridWidth;
	}

	public void setGridHeight(int gridHeight) {
		this.gridHeight = gridHeight;
	}

	public void setFloorSource(List<File> floorSource) {
		this.floorSource = floorSource;
	}

	public void setItemSource(List<File> itemSource) {
		this.itemSource = itemSource;
	}

	public void setFloorImage(BufferedImage[] floorImage) {
		this.floorImage = floorImage;
	}

	public void setItemImage(BufferedImage[] itemImage) {
		this.itemImage = itemImage;
	}

	public void setItems(List<Item> items) {
		this.items = items;
	}

	public void setFloor(int[][] floor) {
		this.floor = floor;
	}

	public void setBlocks(byte[][] blocks) {
		this.blocks = blocks;
	}

	public final void save(File root, StoreUtil storeUtil) {
		storeUtil.onSave(root, this);
	}

	public abstract String getMapName();

	public abstract String getStyleName();

	public abstract String getDeclaration();

	public abstract JDialog getConfigDialog(JFrame component, File root);

	public abstract MapProjection getProjection();

	public abstract void addFloorSource(File file);

	public abstract void addItemSource(File file);

}
